package org.top.rushpeak.edu03.job;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class ContextUtils {
	
	private static ApplicationContext context;
	private ContextUtils(){
		
	}
	
	
	
	public static synchronized ApplicationContext  getContext(){
		if(context==null){
			 context = new ClassPathXmlApplicationContext("classpath*:spring/applicationContext.xml");
		}
		return context;
	}
	
	public static <T>T getService(Class<T> clazz){
		getContext();
		return context.getBean(clazz);
	}
	
	
	public static <T>T getServiceT(String name,Class<T> clazz){
		getContext();
		return context.getBean(name,clazz);
	}
	
}
